#include "symtab.h"

symtab *	pGloabSymTab = new symtab(symtab::scop_gloable);
symtab * pCurSymTab = pGloabSymTab;

void					initSymTab()
{
	pGloabSymTab->m_pPrevTab = NULL;
}
sym *					findSym(const char * strSym)
{
	if(strSym == NULL)
		return NULL;
	std::string str(strSym);
	if(pCurSymTab == NULL)
		return NULL;
	
	symtab * pCur = pCurSymTab;
	sym *res = NULL;
	while(pCur != NULL)
	{
		res = pCur->findSym(str);
		if(res == NULL)
			pCur = pCur->m_pPrevTab;
		else
			return res;
	}
	return res;
}

sym * findSym( const sym * pSym )
{
	return findSym(pSym->m_strSymName.c_str());
}